package design_pattern

import "fmt"

// https://learnku.com/articles/33700

// 历史代码

type OldPlayer struct {

}

func (o *OldPlayer) PlayMP3() {
	fmt.Println("play mp3")
}
func (o *OldPlayer) PlayWMA()  {
	fmt.Println("play wma")
}

// 新接口

type MusicPlayer interface {
	Play(fileName string,fileType string)
}

type PlayerAdaptor struct {
	o OldPlayer
}

func (p *PlayerAdaptor) Play(fileName string, fileType string) {
	switch fileType {
	case "mp3":
		p.o.PlayMP3()
	case "WMA":
		p.o.PlayWMA()
	default:
		fmt.Println("暂不支持此格式："+fileType)


	}
}
